package com.hdaccp.dao.impl;

import java.io.Serializable;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.List;

import com.hdaccp.dao.CommonDao;
import com.hdaccp.dao.CtimeDao;
import com.hdaccp.entity.Ctime;
import com.hdaccp.util.BaseDao;

public class CtimeDaoimpl extends BaseDao implements CommonDao,CtimeDao {
    @Override
    public List getAll() {
        return null;
    }

    @Override
    public Object getById(Serializable id) {
        return null;
    }

    @Override
    public boolean add(Object entity) {
        return false;
    }

    @Override
    public boolean update(Object entity) {
        return false;
    }

    @Override
    public boolean deleteById(Serializable id) {
        return false;
    }

	@Override
	public Ctime getBy(int id) {
		String sql = "select * from `ctime` where zid = ?";
		Ctime c = null;
		Object[] params = {id}; 
		ResultSet rs = super.executeQuery(sql, params);
		try {
			if(rs.next()){
				c = new Ctime();
				c.setId(rs.getInt("id"));
				c.setZid(rs.getInt("zid"));
				c.setDtime(rs.getDate("dtime").toString());
				c.setStime(rs.getDate("stime").toString());
				c.setBtime(rs.getDate("btime").toString());
			}
		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}finally{
			try {
				super.closeAll(rs, rs.getStatement(), rs.getStatement().getConnection());
			} catch (SQLException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
		}
		return c;
	}

	@Override
	public boolean bupd(Ctime c) {
		String sql = "update `ctime` set `btime`=?,`stime`=?,`dtime`=? where zid = ?";
		Object[] params = {c.getBtime(),c.getStime(),c.getDtime(),c.getZid()};
		return super.executeUpdate(sql, params);
	}
}
